<template>
  <div class="login-menu">
    <h1>后台管理系统</h1>
    <el-tabs type="border-card" class="demo-tabs" stretch v-model="activeTab">
      <el-tab-pane name="account">
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><UserFilled /></el-icon>
            <span>帐号登录</span>
          </span>
        </template>
        <loginAccount ref="accountRef"></loginAccount>
      </el-tab-pane>
      <el-tab-pane name="phone">
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><Cellphone /></el-icon>
            <span>手机登录</span>
          </span>
        </template>
        <loginPhone></loginPhone>
      </el-tab-pane>
    </el-tabs>
    <div class="remember_password">
      <el-checkbox v-model="checked" label="记住密码" size="large" />
      <el-link :underline="false">更多</el-link>
    </div>
    <div class="login-btn">
      <el-button type="primary" @click="handClickLogin">登录</el-button>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue'
import loginPhone from '@/views/login/component/login-phone.vue'
import loginAccount from '@/views/login/component/login-account.vue'
export default defineComponent({
  name: 'login-menu',
  components: {
    loginPhone,
    loginAccount
  },
  setup() {
    const checked = ref(true)
    const accountRef = ref<InstanceType<typeof loginAccount>>()
    const activeTab = ref('account')
    const handClickLogin = () => {
      if (activeTab.value === 'account') {
        //账户登录
        accountRef.value?.loginAction(checked.value)
      } else {
        //手机登录
        console.log(activeTab.value)
      }
    }

    return {
      checked,
      handClickLogin,
      accountRef,
      activeTab
    }
  }
})
</script>

<style lang="less" scoped>
.login-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 200px;

  .remember_password {
    width: 100%;
    display: flex;
    justify-content: space-between;
  }
  .login-btn {
    width: 100%;
    button {
      padding: 20px 0;
      width: 100%;
      font-size: 20px;
    }
  }
  .demo-tabs {
    width: 320px;
  }
  .demo-tabs .custom-tabs-label .el-icon {
    vertical-align: middle;
  }
  .demo-tabs .custom-tabs-label span {
    vertical-align: middle;
    margin-left: 4px;
  }
}
</style>
